<%@page pageEncoding="UTF-8" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title><s:property value="appsysYhz.yhzm"/>所属用户</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<base target="_self" />
	</head>
	<jsp:include page="../common/init.jsp"></jsp:include>
	<style type="text/css">
<!--
body,td,th {
	font-size: 12px;
}
-->
</style>
<script type="text/javascript" src="<%=request.getContextPath()%>/webmanager/js/qxgl.js"></script>
<script language="javaScript" src="<%=request.getContextPath()%>/webmanager/js/menu.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/interface/FindYhService.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/engine.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/dwr/util.js"></script>	
<script language="javascript">
	function addrole(addObj,delObj)         
	{         
		estlag = 0 ;        
		for(i=0;i<delObj.length;i++)
		{
			if(delObj.options[i].selected)         
			{         
				estlag = 1;				         
				break;         
			} 
		}         
		for(j=0;j<addObj.length;j++)
		{
			if(addObj.options[j].text==delObj.options[i].text)         
			{         
				estlag = 0  ;       
				break;         
			} 
		}         
		if(estlag == 0)         
			return;         
		rolecnt = addObj.length;        
		rolecnt++;         
		addObj.length = rolecnt ;        
		addObj.options[rolecnt-1].text = delObj.options[i].text;        
		addObj.options[rolecnt-1].value = delObj.options[i].value;      
		for(m=i+1;m<delObj.length;m++)         
		{         
			delObj.options[m-1].text = delObj.options[m].text; 
			delObj.options[m-1].value = delObj.options[m].value;      
		}         
		delObj.length = delObj.length - 1;   
	}        
                
	function adduserrole()         
	{         
		for(i=0;i<frmuserrole.yhbhs.length;i++)         
		{         
			frmuserrole.yhbhs.options[i].selected = true;
		}
		frmuserrole.action="createSsYh.do";    
		frmuserrole.submit()         
	}
	//查询系统用户
	function findYh()
	{
	    //if(document.getElementById("yhm").value!=""||document.getElementById("bmmc").value!="")
	   // {
		    //设置DWR为同步验证
		    DWREngine.setAsync(false);
		    FindYhService.findSysDlyh("<s:property value="yhzbhs"/>",document.getElementById("bmmc").value,document.getElementById("yhm").value,"",callBack);;
			//设置DWR为异步验证
			DWREngine.setAsync(true);
	   // }
	}
	function callBack(data)
	{
	     if(data!=null)
	     {
		     frmuserrole.sysYhbhs.length=data.length;
		     for(var i=0;i<data.length;i++)
		     {
		         frmuserrole.sysYhbhs.options[i].text=data[i].yhm
		         +"--"+data[i].xm+"--"+data[i].bmmc;
		         frmuserrole.sysYhbhs.options[i].value=data[i].yhbh;
		     }
	     }
	}
	mpmenu1=new mMenu(' 保 存 ','adduserrole()','script','<%=request.getContextPath() %>/images/img_ht_wz_8.gif','62','24','2','100','2');
	mpmenu2=new mMenu(' 关 闭 ','window.close()','script','<%=request.getContextPath() %>/images/img_ht_wz_8.gif','62','24','2','100','2');
</script>
	<%
		response.setHeader("Pragma", "No-cache");
		response.setHeader("Cache-Control", "no-cache");
		response.setDateHeader("Expires", 0);
		String path = request.getContextPath();
	%>
	<body bgcolor="#F3F7FD">
<s:form method="POST" name="frmuserrole" >
<table cellspacing="0" cellpadding="0" width="100%" class="main_tab1">
 <tr>
        <td colspan="3" class="main_tab1_td3">
		<input type="hidden" name="yhzbhs" value="<s:property value="yhzbhs"/>">      
		<table border="0" cellpadding="0" cellspacing="0" width="100%" class="table" >
		   <tr>
               <td align="left"  valign="bottom" height="25" >
               &nbsp;用户名：<input id="yhm" name="yhm" type="text"  size="8" maxlength="20" value="" >
               &nbsp;所属部门：<input id="bmmc" name="bmmc" type="text" size="8" maxlength="20" value="" >
                  &nbsp;
                  <a href="javascript:void(0)" onfocus="this.blur()" >
					<img src="<%=request.getContextPath() %>/images/img_ht_wz_46.gif" border="0"  onclick="javascript:findYh();" ></a>
              </td>
              <td>
              &nbsp;
              </td>
              <td >
              &nbsp;
              </td>
             </tr>
             <tr height="25">
               <td>
				&nbsp;<strong>所有用户：</strong>(格式：用户名--姓名--所属部门)
              </td>
              <td>
              &nbsp;
              </td>
              <td>
              &nbsp;<strong>当前用户：</strong>(格式：用户名--姓名--所属部门)
              </td>
             </tr>
			<tr>
			<tr>
			<td align="right" >       
				<select name="sysYhbhs" size="23" multiple="multiple" class="form1" style="width: 370;">
					  	<s:iterator value="dlyhList" status="index">
					  	<option value="<s:property value="yhbh"/>"><s:property value="yhm"/>--<s:property value="xm"/>--<s:property value="bmmc"/></option>
					  	</s:iterator>       
			</select>           	  
				</td>              
				<td>     
					<p align="center">
					<a href="javascript:void(0)" onfocus="this.blur()" ><img src="<%=path %>/images/turn-right.gif" border="0" onclick="addrole(frmuserrole.yhbhs,frmuserrole.sysYhbhs);"></a><br><br>
					<a href="javascript:void(0)" onfocus="this.blur()" ><img src="<%=path %>/images/turn-left.gif"  border="0" onclick="addrole(frmuserrole.sysYhbhs,frmuserrole.yhbhs);"></a>     
					</p>      
				</td>    
				<td align="left">
					  <select name="yhbhs" size="23" multiple="multiple" class="form1" style="width: 370;">
					  	<s:iterator value="currDlyhList" status="index">
					  	<option value="<s:property value="yhbh"/>"><s:property value="yhm"/>--<s:property value="xm"/>--<s:property value="bmmc"/></option>
					  	</s:iterator>
					</select>    
				</td>     
			</tr>      
			<tr>      
   	<td align="center" colspan="3">
		<div class="butk">
		<div class="btn_01">
		<a href="#" onclick="adduserrole()">保&nbsp;存</a>
		</div>
		</div>
   	</td>    
			</tr>      
		</table> 
		</td>
		</tr>
</table>
</s:form> 

	</body>
</html>
